// columns.ts

import DictTag, { DictValueEnum } from "@/components/DictTag";
import { createIcon } from "@/utils/IconUtil";
import { PlusOutlined, SyncOutlined } from "@ant-design/icons";
import { ProColumns } from "@ant-design/pro-table";
import { Avatar, Divider, Dropdown, MenuProps, Popconfirm, Space, Switch, Tag, Typography } from "antd";

// 定义所有列的工厂函数
export const createTableColumns = (
	handleColumnEditor: (record: API.System.DictData) => void,
	handleColumnRemove: (record: API.System.DictData) => void
): ProColumns<API.System.DictData>[] => {
	return [
		{
			title: "字典标签",
			dataIndex: "dictLabel",
			valueType: "text",
			width: "200",
			ellipsis: true,
			fixed: "left"
		},
		{
			title: "字典键值",
			dataIndex: "dictValue",
			valueType: "text"
		},
		{
			title: "样式",
			dataIndex: "color",
			valueType: "text",
			hideInSearch: true,
			render: (_, record) => {
				return (
					<>
						{record.color ? (
							<Tag bordered={false} color={record.color}>
								{record.color}
							</Tag>
						) : (
							"-"
						)}
					</>
				);
			}
		},
		{
			title: "字典排序",
			dataIndex: "sort",
			valueType: "digit",
			sorter: (a, b) => a.sort - b.sort
		},
		// {
		// 	title: "备注",
		// 	dataIndex: "remark",
		// 	valueType: "textarea",
		// 	hideInSearch: true
		// },
		{
			title: "操作",
			dataIndex: "option",
			width: "220px",
			valueType: "option",
			fixed: "right",
			render: (_, record: any) => {
				return (
					<>
						<Space size={1} split={<Divider type="vertical" />}>
							<Typography.Link
								key="edit"
								onClick={() => {
									handleColumnEditor(record);
								}}
							>
								编辑
							</Typography.Link>
							<Typography.Link
								type="danger"
								key="remove"
								onClick={() => {
									handleColumnRemove(record);
								}}
							>
								删除
							</Typography.Link>
							{/* <Popconfirm
								placement="bottomRight"
								title={"提示"}
								description={
									<>
										确认删除该：
										<Typography.Text style={{ fontWeight: "600" }}>{record?.dictLabel}</Typography.Text> 字典标签!
									</>
								}
								onConfirm={() => {
									handleColumnRemove(record);
								}}
								okText="确认"
								cancelText="取消"
							>
								<Typography.Link type="danger" key="remove">
									删除
								</Typography.Link>
							</Popconfirm> */}
						</Space>
					</>
				);
			}
		}
	];
};
export const title = "字典数据";
export const pagination = {
	showQuickJumper: true,
	showSizeChanger: true
};

export const formTitle = ["新增字典数据", "编辑数据字典"];
